﻿using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEditor;

public class TestEditor
{
    private static string DLLPATH = "Assets/GameData/Data/HotFix/HotFix.dll";
    private static string PBDPATH = "Assets/GameData/Data/HotFix/HotFix.pdb";
    private static Sprite ttt;

    [MenuItem("Tools/测试加载")]
    public static void TestLoad()
    {
        ttt = AssetDatabase.LoadAssetAtPath<Sprite>("Assets/GameData/UGUI/Test1.png");
    }

    [MenuItem("Tools/测试卸载")]
    public static void TestUnLoad()
    {
        Resources.UnloadAsset(ttt);
        //对引用进行了释放，但是还存在在编辑器内存
    }

    [MenuItem("Tools/修改热更dll后缀为txt")]
    public static void ChangeDllName()
    {
        if (File.Exists(DLLPATH))
        {
            string targetPath = DLLPATH + ".txt";
            if (File.Exists(targetPath))
            {
                File.Delete(targetPath);
            }
            File.Move(DLLPATH, targetPath);
        }

        if (File.Exists(PBDPATH))
        {
            string targetPath = PBDPATH + ".txt";
            if (File.Exists(targetPath))
            {
                File.Delete(targetPath);
            }
            File.Move(PBDPATH, targetPath);
        }
        AssetDatabase.Refresh();
        AssetDatabase.Refresh();
    }
}
